#ifndef     __HANDLER_TASK_H
#define     __HANDLER_TASK_H

#include "../rtos/thread.h"
#include "../rtos/message_queue.h"
#include "../utils/object.h"
#include "../utils/byte_view.h"

namespace task {

class HandlerTask_t : public rtos::Thread_t<HandlerTask_t, 2048, osPriorityHigh1> {

public:
    inline void post(const utils::ByteView_t &bw) {
        m_mq.put(bw);
    }

    void run();

private:
    static void on_motor_ctrl(const utils::ByteView_t &bw);
    static void on_music_volume_ctrl(const utils::ByteView_t &bw);
    static void on_music_play(const utils::ByteView_t &bw);
    static void on_delivery(const utils::ByteView_t &bw);
    static void on_display(const utils::ByteView_t &bw);
    static void on_set_price(const utils::ByteView_t &bw);

private:
    rtos::MessageQueue_t<utils::ByteView_t, 10> m_mq;
};

extern utils::Object<HandlerTask_t> handlerTask;

}

#endif
